<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>SILVERCODERS DocToText: SILVERCODERS DocToText</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">SILVERCODERS DocToText
   &#160;<span id="projectnumber">4.0.1512</span>
   </div>
   <div id="projectbrief">Converts DOC, XLS, XLSB, PPT, RTF, ODF (ODT, ODS, ODP), OOXML (DOCX, XLSX, PPTX), iWork (PAGES, NUMBERS, KEYNOTE), ODFXML (FODP, FODS, FODT), PDF, EML and HTML documents to plain text. Extracts metadata and annotations.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li class="current"><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">SILVERCODERS DocToText </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="intro"></a>
Introduction</h1>
<pre class="fragment">DocToText - Converts DOC, XLS, XLSB, PPT, RTF, ODF (ODT, ODS, ODP),
           OOXML (DOCX, XLSX, PPTX), iWork (PAGES, NUMBERS, KEYNOTE),
           ODFXML (FODP, FODS, FODT), PDF, EML and HTML documents to plain text.
           Extracts metadata and annotations.
</pre><h1><a class="anchor" id="usage"></a>
Usage</h1>
<h2><a class="anchor" id="GCC"></a>
How to use distributed, compiled binaries with GCC</h2>
<pre class="fragment">Binaries have been compiled using GCC, so usage will be very simple here.
We distribute binaries within one single catalog, where we can find all necessary files
(include files -&gt; .h, library files -&gt; .dll, .so, .dylib).
So, all we have to do is to modify few options: LDFLAGS (-L/path/to/doctotext)
and CXXFLAGS (-I/path/to/doctotext). Also, do not forget to specify LD_LIBRARY_PATH.
It must also contain path to doctotext. If we forget about this, we may get undefined references.
Finally, we have to add one more option to the linker: "-ldoctotext". Now we can create example file, main.cpp
</pre><div class="fragment"><div class="line">*   #include <span class="stringliteral">&quot;metadata.h&quot;</span></div>
<div class="line">*   #include <span class="stringliteral">&quot;plain_text_extractor.h&quot;</span></div>
<div class="line">*</div>
<div class="line">*   #include &lt;iostream&gt;</div>
<div class="line">*   #include &lt;string&gt;</div>
<div class="line">*</div>
<div class="line">*   <span class="keyword">using namespace </span>doctotext;</div>
<div class="line">*</div>
<div class="line">*   <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])</div>
<div class="line">*   {</div>
<div class="line">*       std::string file_name = <span class="stringliteral">&quot;example.doc&quot;</span>;</div>
<div class="line">*       <a class="code" href="classdoctotext_1_1PlainTextExtractor.html">PlainTextExtractor</a> extractor;</div>
<div class="line">*       extractor.<a class="code" href="classdoctotext_1_1PlainTextExtractor.html#af8c15ef99a89289ae637a5c746fe4ee7">setVerboseLogging</a>(<span class="keyword">true</span>);</div>
<div class="line">*       <a class="code" href="classdoctotext_1_1Metadata.html">Metadata</a> meta;</div>
<div class="line">*       <span class="keywordflow">if</span> (!extractor.<a class="code" href="classdoctotext_1_1PlainTextExtractor.html#a12fc8d7497365dd4e285d734b6f83440">extractMetadata</a>(file_name, meta))</div>
<div class="line">*           <span class="keywordflow">return</span> 1;</div>
<div class="line">*       std::cout &lt;&lt; <span class="stringliteral">&quot;Author: &quot;</span> &lt;&lt; meta.author() &lt;&lt; std::endl;</div>
<div class="line">*       std::cout &lt;&lt; <span class="stringliteral">&quot;Last modified by: &quot;</span> &lt;&lt; meta.lastModifiedBy() &lt;&lt; std::endl;</div>
<div class="line">*       std::string text;</div>
<div class="line">*       <span class="keywordflow">if</span> (!extractor.<a class="code" href="classdoctotext_1_1PlainTextExtractor.html#a64ee898ddf7450ff51d4f7026fa32697">processFile</a>(file_name, text))</div>
<div class="line">*           <span class="keywordflow">return</span> 1;</div>
<div class="line">*       std::cout &lt;&lt; text &lt;&lt; std::endl;</div>
<div class="line">*       <span class="keywordflow">return</span> 0;</div>
<div class="line">*   }</div>
<div class="line">*   </div>
</div><!-- fragment --><p>The shortest way to build example program is to execute this command: LD_LIBRARY_PATH=./doctotext g++ -o example main.cpp -I./doctotext/ -L./doctotext/ -ldoctotext Of course, ./doctotext is a catalog with include and library files we distribute. Create some .doc file named example.doc. Put within executable file. Now we can run application: LD_LIBRARY_PATH=./doctotext example We should be able to see extracted text, author of the file, and a person who last has modified it. There is one more thing to remember: There is "resources" catalog inside our "doctotext" dir. It is used by PDF parser. We have to put this catalog in the same path where executable is, otherwise PDF parser may fail sometimes.</p>
<h2><a class="anchor" id="CFront"></a>
How to use the distributed, compiled binaries with CFront</h2>
<pre class="fragment">You can build application using doctotext in similiar way as with GCC. But there is one important thing
you need to know. You must not use any function from doctotext which requires use of Standard Template Library (STL).
To be sure, do not use any object from std namespace. The reason is that we are using GCC and implementation
of STL differs too much from the one provided by CFront. But it is possible not to use STL, since we provide API
which do not use that library. Simple rewrite main.cpp from previous chapter in following way:
</pre><div class="fragment"><div class="line">*   #include <span class="stringliteral">&quot;metadata.h&quot;</span></div>
<div class="line">*   #include <span class="stringliteral">&quot;plain_text_extractor.h&quot;</span></div>
<div class="line">*</div>
<div class="line">*   #include &lt;iostream&gt;</div>
<div class="line">*</div>
<div class="line">*   <span class="keyword">using namespace </span>doctotext;</div>
<div class="line">*</div>
<div class="line">*   <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])</div>
<div class="line">*   {</div>
<div class="line">*       <span class="keywordtype">char</span> file_name[] = <span class="stringliteral">&quot;example.doc&quot;</span>;</div>
<div class="line">*       <a class="code" href="classdoctotext_1_1PlainTextExtractor.html">PlainTextExtractor</a> extractor;</div>
<div class="line">*       extractor.<a class="code" href="classdoctotext_1_1PlainTextExtractor.html#af8c15ef99a89289ae637a5c746fe4ee7">setVerboseLogging</a>(<span class="keyword">true</span>);</div>
<div class="line">*       <a class="code" href="classdoctotext_1_1Metadata.html">Metadata</a> meta;</div>
<div class="line">*       <span class="keywordflow">if</span> (!extractor.<a class="code" href="classdoctotext_1_1PlainTextExtractor.html#a12fc8d7497365dd4e285d734b6f83440">extractMetadata</a>(file_name, meta))</div>
<div class="line">*           <span class="keywordflow">return</span> 1;</div>
<div class="line">*       std::cout &lt;&lt; <span class="stringliteral">&quot;Author: &quot;</span> &lt;&lt; meta.author() &lt;&lt; std::endl;</div>
<div class="line">*       std::cout &lt;&lt; <span class="stringliteral">&quot;Last modified by: &quot;</span> &lt;&lt; meta.lastModifiedBy() &lt;&lt; std::endl;</div>
<div class="line">*       <span class="keywordtype">char</span>* text;</div>
<div class="line">*       <span class="keywordflow">if</span> (!extractor.<a class="code" href="classdoctotext_1_1PlainTextExtractor.html#a64ee898ddf7450ff51d4f7026fa32697">processFile</a>(file_name, text))</div>
<div class="line">*           <span class="keywordflow">return</span> 1;</div>
<div class="line">*       std::cout &lt;&lt; text &lt;&lt; std::endl;</div>
<div class="line">*       <span class="keyword">delete</span>[] text;</div>
<div class="line">*       <span class="keywordflow">return</span> 0;</div>
<div class="line">*   }</div>
<div class="line">*   </div>
</div><!-- fragment --><p>Note that text and file_name are type of char*, not std::string. Now everything should be working as expected.</p>
<h2><a class="anchor" id="MSVC"></a>
How to use the distributed, compiled binaries with MSVC</h2>
<pre class="fragment">Binaries for windows have been compiled with MinGW, thus cannot be used in MSVC enviroment easily.
But it does not concern C API. On this level, MinGW libraries are compatible with MSVC. Knowing about that,
we provide additional file: doctotext_c_api.h. It contains, as indicated by the file name, list of
functions which use C-naming conventions. Thanks to this API, we can use binaries produced by MinGW
in other enviroments, like MSVC.
In order to compile sample program with MSVC, we need following files: libdoctotext.a and
doctotext_c_api.h. In compiler options, we have to add two paths: one include path (we have to specify directory
where doctotext_c_api.h lies) and one library path (where we need to provide path to libdoctotext.a).
Now, in linker options we have to add one file: "libdoctotext.a". That's all. We can create main.cpp file:
</pre><div class="fragment"><div class="line">*   #include <span class="stringliteral">&quot;doctotext_c_api.h&quot;</span></div>
<div class="line">*   #include &lt;conio.h&gt;</div>
<div class="line">*   #include &lt;time.h&gt;</div>
<div class="line">*</div>
<div class="line">*   <span class="keywordtype">int</span> main()</div>
<div class="line">*   {</div>
<div class="line">*       <span class="comment">//Create style and extractor params objects</span></div>
<div class="line">*       DocToTextExtractorParams* params = doctotext_create_extractor_params();</div>
<div class="line">*       DocToTextFormattingStyle* style = doctotext_create_formatting_style();</div>
<div class="line">*       doctotext_formatting_style_set_url_style(style, DOCTOTEXT_URL_STYLE_EXTENDED);</div>
<div class="line">*       doctotext_extractor_params_set_verbose_logging(params, 1);</div>
<div class="line">*       doctotext_extractor_params_set_formatting_style(params, style);</div>
<div class="line">*</div>
<div class="line">*       <span class="comment">//Extract text</span></div>
<div class="line">*       DocToTextExtractedData* data = doctotext_process_file(<span class="stringliteral">&quot;example.doc&quot;</span>, params, NULL);</div>
<div class="line">*       <span class="comment">//We should check if &quot;data&quot; is NULL!</span></div>
<div class="line">*       printf(<span class="stringliteral">&quot;\n\ndata: %s\n&quot;</span>, doctotext_extracted_data_get_text(data));</div>
<div class="line">*</div>
<div class="line">*       <span class="comment">//Extract metadata</span></div>
<div class="line">*       DocToTextMetadata* metadata = doctotext_extract_metadata(<span class="stringliteral">&quot;example.doc&quot;</span>, params, NULL);</div>
<div class="line">*       <span class="comment">//We should check if &quot;metadata&quot; is NULL!</span></div>
<div class="line">*       printf(<span class="stringliteral">&quot;author: %s\n&quot;</span>, doctotext_metadata_author(metadata));</div>
<div class="line">*       <span class="keywordtype">char</span> date[64];</div>
<div class="line">*       <span class="comment">//Check creation date</span></div>
<div class="line">*       strftime(date, 64, <span class="stringliteral">&quot;%Y-%m-%d %H:%M:%S&quot;</span>, doctotext_metadata_creation_date(metadata));</div>
<div class="line">*       printf(<span class="stringliteral">&quot;creation date: %s\n&quot;</span>, doctotext_variant_get_string(doctotext_metadata_get_field(metadata, <span class="stringliteral">&quot;creation date&quot;</span>)));</div>
<div class="line">*</div>
<div class="line">*       <span class="comment">//We have to release those data:</span></div>
<div class="line">*       doctotext_free_extracted_data(data);</div>
<div class="line">*       doctotext_free_extractor_params(params);</div>
<div class="line">*       doctotext_free_formatting_style(style);</div>
<div class="line">*       getch();</div>
<div class="line">*       <span class="keywordflow">return</span> 0;</div>
<div class="line">*   }</div>
<div class="line">*   </div>
</div><!-- fragment --><p>Now we can compile our simple program. Of course, do not forget to put all *.dll into directory where executable program is. That's all, program should be working now, if we do not forget to provide example.doc file of course. There is one more thing to remember: Within binaries dir, there is "resources" catalog. It is used by PDF parser. We have to put this catalog in the same path where executable is, otherwise PDF parser may fail sometimes. </p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>
